CREATE TABLE IF NOT EXISTS contacts (
  id CHAR(36) NOT NULL,
  user_id CHAR(36) NOT NULL,
  fullname VARCHAR(128) NOT NULL,
  phone VARCHAR(16) NOT NULL,
  email VARCHAR(128) NULL,
  company VARCHAR(128) NULL,
  photo VARCHAR(40) NULL,
  website TEXT NULL,
  birthday DATE NULL,
  notes VARCHAR(255) NULL,
  created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
  updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
  CONSTRAINT contacts_id_primary PRIMARY KEY (id),
  CONSTRAINT contacts_user_id_photo_unique UNIQUE (user_id, photo),
  CONSTRAINT contacts_user_id_foreign FOREIGN KEY (user_id)
    REFERENCES users (id)
    ON DELETE CASCADE
    ON UPDATE RESTRICT
);
